package com.ying.dto;

import com.ying.entity.MachineEntity;

import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * Created by Administrator on 2017/10/16.
 */
public class MachineDTO {
    private Long id;
    private String machineId;
    private String energy;
    private String updatetime;

    public MachineDTO() {
    }

    public MachineDTO(MachineEntity o) {
        copyValue(o);
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getMachineId() {
        return machineId;
    }

    public void setMachineId(String machineId) {
        this.machineId = machineId;
    }

    public String getEnergy() {
        return energy;
    }

    public void setEnergy(String energy) {
        this.energy = energy;
    }

    public String getUpdatetime() {
        return updatetime;
    }

    public void setUpdatetime(String updatetime) {
        this.updatetime = updatetime;
    }

    public void copyValue(MachineEntity machineEntity) {
        this.id = machineEntity.getId();
        this.machineId = machineEntity.getMachineId();
        this.energy = machineEntity.getEnergy();
        this.updatetime = ZonedDateTime.ofInstant(
                new Date(machineEntity.getUpdatetime()).toInstant(), ZoneId.systemDefault())
        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"));
    }
}
